package com.huadi.firematerialident.service;

import com.huadi.firematerialident.dao.FireInfoDaoImpl;
import com.huadi.firematerialident.po.Appraisal;
import com.huadi.firematerialident.po.FireInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class FireInfoServiceImpl implements FireInfoService{

    @Autowired
    FireInfoDaoImpl fireInfoDao;
    @Override
    public int addFireInfo(FireInfo fireinfo) {
        return fireInfoDao.addFireInfo(fireinfo);
    }

    @Override
    public int updateFireInfo(FireInfo fireinfo) {
        return fireInfoDao.updateFireInfo(fireinfo);
    }

    @Override
    public int deleteFireInfoByID(String fireinfoID) {
        return fireInfoDao.deleteFireInfoByID(fireinfoID);
    }

    @Override
    public List<Map<String,Object>> selectFireInfoByID(String fireinfoID) {
        return fireInfoDao.selectFireInfoByID(fireinfoID);
    }

    @Override
    public List<Map<String,Object>> getAllFireInfo() {
        return fireInfoDao.getAllFireInfo();
    }

    @Override
    public FireInfo selectFireInfoByID_class(String id){
        List<Map<String ,Object>> list = fireInfoDao.selectFireInfoByID(id);
        FireInfo fireInfo = new FireInfo();
        fireInfo.setFireInfoID((String) list.get(0).get("FireInfoID"));
        fireInfo.setFireType((String) list.get(0).get("FireType"));
        fireInfo.setFireLevel((String) list.get(0).get("FireLevel"));
        fireInfo.setFireTime((LocalDate) list.get(0).get("FireTime"));
        fireInfo.setFireAdd((String) list.get(0).get("FireAdd"));
        fireInfo.setMoreInfo((String) list.get(0).get("MoreInfo"));
        fireInfo.setArchivingStatus((String) list.get(0).get("ArchivingStatus"));
        fireInfo.setLogicalAddDel((boolean) list.get(0).get("LogicalAddDel"));
        fireInfo.setLastModification((LocalDateTime) list.get(0).get("LastModification"));
        return fireInfo;
    }
}
